package com.cspm.ahjy.bc.office.word.domain;

import java.util.ArrayList;
import java.util.List;

/**
 * 文档中的段落，对应XML中的<w:p>标签
 * @author ServerZhang
 * @date 2017年9月27日
 */
public class MSParagraph {

	private Integer paragraphNum;//所在真实段落
	private String text = null;//段落的文字内容
	
	private MSFont wholeFont = null;//整段操作时才对此属性赋值
	
	/*private String fontName="ksks";//字体
	private Integer fontSize=0;//字号
	private String color="000000";//颜色，默认黑色
	private Boolean bold=false;//加粗
	private Boolean italic=false;//斜体
	private String underline="";//下划线样式 
	private String underlineColor = "000000";//下划线颜色，默认黑色
	private Boolean strike=false;//删除线
	private Boolean dbStrike=false;//双删除线
	private String stress = "";//着重号样式
*/	
	private String alignment = "double";// 对齐方式：分别为左对齐left、居中center、右对齐right、两端对齐double、分散对齐distribute
	private Integer indentationLeft = 0; //左缩进（只支持字符）
	private Integer indentationRight = 0; //右缩进（只支持字符）
	private Integer indentationFirstline = 0; //首行缩进（只支持字符）
	private Integer indentationHanging = 0; //悬挂缩进（只支持字符）
	
	private Integer beforeLines = 0;//段前
	private Integer afterLines = 0;//段后
	
	private String lineRule = "";//行距: 最小值at-least,固定值exact,n倍行距auto
	private Integer line = 0;//行距值
	private String lineDescription = "";//行距说明
	
	private Integer outlineLvl = 0;//大纲级别
	
	private MSItem msItem = null;//项目编号或符号
	
	private MSShadow msShadow = null;//段落底纹
	
	private String colsType = null;//分栏样式：一栏、两栏、三栏、“偏左”的两栏、“偏右”的两栏、4...栏
	
	private Integer firstWordSink = null;//首字下沉
	
	
	private List<MSFont> fonts = new ArrayList<MSFont>();//包含的所有RUN对应的字体
	
	public void addFonts(MSFont font){
		this.fonts.add(font);
	}
	
	public MSParagraph(){
		
	}
	
	/**
	 * 判断两个段落可能相等，仅用于判断相邻段落调换位置
	 * @param paragraph
	 * @return
	 * @author ServerZhang
	 * @date 2017年10月11日
	 */
	public Boolean maybeEquals(MSParagraph paragraph){
		if (paragraph == null) {
			return Boolean.FALSE;
		}
		String text1 = paragraph.getText();
		String text2 = this.text;
		if (text1 == null && text2 == null) {//图片
			MSFont wholeFont1 = this.wholeFont;
			MSFont wholeFont2 = paragraph.getWholeFont();
			if (wholeFont2 != null && wholeFont2.maybeEquals(wholeFont1)) {
				return Boolean.TRUE;
			}
			return Boolean.FALSE;
		}else if (text1 == null || text2 == null) {
			return Boolean.FALSE;
		}
		
		int length1 = text1.length();
		String subStr1 = length1 > 12 ? text1.substring(0, 12) : text1.substring(0, length1);//取段首12字作比对，相同则认为是同一段落
		
		int length2 = text2.length();
		String subStr2 = length2 > 12 ? text2.substring(0, 12) : text2.substring(0, length2);//取段首12字作比对，相同则认为是同一段落
		
		if (subStr1.equals(subStr2)) {
			return Boolean.TRUE;
		}
		return Boolean.FALSE;
		
	}

	
	
	public Integer getFirstWordSink() {
		return firstWordSink;
	}

	public void setFirstWordSink(Integer firstWordSink) {
		this.firstWordSink = firstWordSink;
	}

	public String getColsType() {
		return colsType;
	}

	public void setColsType(String colsType) {
		this.colsType = colsType;
	}

	public MSShadow getMsShadow() {
		return msShadow;
	}

	public void setMsShadow(MSShadow msShadow) {
		this.msShadow = msShadow;
	}

	public String getLineDescription() {
		return lineDescription;
	}

	public void setLineDescription(String lineDescription) {
		this.lineDescription = lineDescription;
	}

	public Integer getParagraphNum() {
		return paragraphNum;
	}

	public void setParagraphNum(Integer paragraphNum) {
		this.paragraphNum = paragraphNum;
	}

	public String getText() {
		return text;
	}

	public void setText(String text) {
		this.text = text;
	}

	public MSFont getWholeFont() {
		return wholeFont;
	}

	public void setWholeFont(MSFont wholeFont) {
		this.wholeFont = wholeFont;
	}

	public String getAlignment() {
		return alignment;
	}

	public void setAlignment(String alignment) {
		this.alignment = alignment;
	}

	public Integer getIndentationLeft() {
		return indentationLeft;
	}

	public void setIndentationLeft(Integer indentationLeft) {
		this.indentationLeft = indentationLeft;
	}

	public Integer getIndentationRight() {
		return indentationRight;
	}

	public void setIndentationRight(Integer indentationRight) {
		this.indentationRight = indentationRight;
	}

	public Integer getIndentationFirstline() {
		return indentationFirstline;
	}

	public void setIndentationFirstline(Integer indentationFirstline) {
		this.indentationFirstline = indentationFirstline;
	}

	public Integer getIndentationHanging() {
		return indentationHanging;
	}

	public void setIndentationHanging(Integer indentationHanging) {
		this.indentationHanging = indentationHanging;
	}

	public Integer getBeforeLines() {
		return beforeLines;
	}

	public void setBeforeLines(Integer beforeLines) {
		this.beforeLines = beforeLines;
	}

	public Integer getAfterLines() {
		return afterLines;
	}

	public void setAfterLines(Integer afterLines) {
		this.afterLines = afterLines;
	}

	public String getLineRule() {
		return lineRule;
	}

	public void setLineRule(String lineRule) {
		this.lineRule = lineRule;
	}

	public Integer getLine() {
		return line;
	}

	public void setLine(Integer line) {
		this.line = line;
	}

	public Integer getOutlineLvl() {
		return outlineLvl;
	}

	public void setOutlineLvl(Integer outlineLvl) {
		this.outlineLvl = outlineLvl;
	}

	public List<MSFont> getFonts() {
		return fonts;
	}

	public void setFonts(List<MSFont> fonts) {
		this.fonts = fonts;
	}

	public MSItem getMsItem() {
		return msItem;
	}

	public void setMsItem(MSItem msItem) {
		this.msItem = msItem;
	}
	
	
	
}
